package android.slc.appbase.ui.vd;

import android.slc.appbase.ui.vd.wrapper.IBaseListPageByFxWrapper;
import android.slc.box.adapter.LoadMoreDataFormatByFx;
import android.slc.box.adapter.PageModel;

import java.io.Serializable;


/**
 * 基础的分页加载盒子vm
 *
 * @author slc
 * @date 2020-08-25 16:13
 */
public abstract class BaseListPageVdByFx<T extends Serializable, VB extends BaseListCommonVmBox<T>> extends BaseListCommonVd<T, VB>
        implements LoadMoreDataFormatByFx.LoadModelCallbackFx<T> {

    protected IBaseListPageByFxWrapper<T> getListPageWrapper() {
        if (vmBox instanceof IBaseListPageByFxWrapper<?>) {
            return (IBaseListPageByFxWrapper<T>) vmBox;
        }
        throw new RuntimeException("vmBox没有实现IBaseListPageWrapper接口");
    }

    @Override
    protected void initView() {
        super.initView();
        getListPageWrapper().getLoadMoreDataFormatByFx().setLoadModelCallback(this);
    }

    @Override
    public void loadMoreEnd() {
        //swipeRecycler.loadMoreEnd();
    }

    @Override
    public void setRefreshing(boolean refresh) {
        if (refresh) {
            notifyRefreshing();
        }
        //swipeRecycler.setRefreshing(refresh);
    }

    @Override
    public void loadMoreComplete(PageModel<T> pageModel) {
        //什么也不做
    }

    @Override
    public void loadMoreFail(int pageIndex, int errorCode, String errorMsg) {
    }

}
